cmake_minimum_required(VERSION 3.10)
project(endless)

option(BUILD_TESTS "Build and run tests" OFF)
option(BUILD_WEB "Build web frontend" ON)
option(BUILD_LEGACY_ADAPTER "Build vendor/open_ipc_legacy_adapter (aarch64 only)" ON)

if(PLATFORM STREQUAL "aarch64")
    include(${CMAKE_SOURCE_DIR}/cmake/aarch64.cmake)
elseif(PLATFORM STREQUAL "3516cv610")
    include(${CMAKE_SOURCE_DIR}/cmake/3516cv610.cmake)
else()
    message(FATAL_ERROR "Unsupported platform: ${PLATFORM}. Supported: aarch64, 3516cv610")
endif()

find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
    set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
    set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_PROGRAM})
endif()

add_subdirectory(common)
# add_subdirectory(hal)
add_subdirectory(base)
add_subdirectory(foundation)
add_subdirectory(applications)
add_subdirectory(tools)

# Vendor: open_ipc_legacy_adapter (embedded into CMake as a custom target)
